﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace MediaPlayer.Converter
{
    class TimeSpanToSeconds : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                Nullable<TimeSpan> timeSpan = value as Nullable<TimeSpan>;
                if (timeSpan != null && timeSpan.HasValue)
                    return timeSpan.Value.TotalSeconds;
            }

            return 0;    
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                Nullable<Double> seconds = value as Nullable<Double>;
                if (seconds != null && seconds.HasValue)
                    return new TimeSpan(0, 0, (int)seconds.Value);
            }

            return 0;
        }
    }

    class TimeSpanToDuree : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            TimeSpan timeSpan = TimeSpan.Zero;

            if (value != null)
            {
                try
                {
                    timeSpan = TimeSpan.FromTicks((long)value);
                }
                catch
                { }
            }

            return timeSpan.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return 0;
        }
    }

    class PathToBitmap : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
           
            return 0;
        }
    }

}
